package com.cmii.sjw.department.control.jsc.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.cmii.sjw.department.control.jsc.model.DistrictDetail;
import com.cmii.sjw.department.control.jsc.service.DistrictDetailService;
import com.cmii.sjw.department.control.jsc.util.Result;
import com.cmii.sjw.department.control.jsc.vo.DistrictDetailVO;
import org.springframework.web.bind.annotation.*;

import jakarta.annotation.Resource;
import java.util.List;

/**
 * 区县详情Controller
 *
 * @author lizheng
 * @date 2024-11-19
 */
@RestController
@CrossOrigin
@RequestMapping("/district")
public class DistrictDetailController {

    @Resource
    private DistrictDetailService districtDetailService;

    /**
     * 区县详情
     *
     * @return 列表
     */
    @PostMapping("/list")
    public Result<IPage<DistrictDetail>> list( Integer orderNum,Integer isDeleted,
                                              @RequestParam(defaultValue = "1") Integer current,
                                              @RequestParam(defaultValue = "10") Integer size) {
        IPage<DistrictDetail> list = districtDetailService.list(orderNum, isDeleted,current, size);
        return Result.success(list);
    }

    /**
     * 区县详情
     *
     * @return 根据regional_level查出名称
     */
    @PostMapping("/level")
    public Result<List<DistrictDetailVO>> list() {
        List<DistrictDetailVO> list = districtDetailService.listByRegionalLevel();
        return Result.success(list);
    }
}
